package loader.views 
{
	import common.IDisposable;
	import flash.events.Event;
	import loader.ILoaderModel;
	import loader.ILoaderView;
	/**
	 * ...
	 * @author Luke Van In
	 */
	public class LoaderTraceView implements ILoaderView, IDisposable
	{
		
		private var _model:ILoaderModel;
		
		
		public function LoaderTraceView(model:ILoaderModel) 
		{
			this._model = model;
			
			this.update();
			
			this.addEvents();
		}
		
		
		private function addEvents():void
		{
			this._model.addEventListener(Event.CHANGE, this.onModelChange);
		}
		
		
		private function removeEvents():void
		{
			this._model.removeEventListener(Event.CHANGE, this.onModelChange);
		}
		
		
		private function onModelChange(e:Event):void
		{
			this.update();
		}
		
		
		private function update():void
		{
			trace("LoaderTraceView > update: progress:" + this._model.getProgress().toFixed(2));
		}
		
		
		public function dispose():void 
		{
			this.removeEvents();
		}
		
	}

}